<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
    <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/layui@2.6.8/dist/css/layui.css">
    <script src="//cdn.jsdelivr.net/npm/layui@2.6.8/dist/layui.js" charset="utf-8"></script>
</head>

<body>
    <div class="layui-container" style="margin: 15px;padding: 15px;background-color: #fff;">
        <div class="layui-form">
            {:token_field()}
            <div class="layui-form-item">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-block">
                    <input type="text" name="phone" value="13812345678" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="pwd" value="123456" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" onclick="dologin()">登录</button>
                </div>
            </div>
        </div>
    </div>

    <script>
        var $ = layui.jquery;

        function dologin() {
            var phone = $('input[name="phone"]').val(),
                pwd = $('input[name="pwd"]').val();

            $.post('/account/dologin', { phone, pwd }, function (res) {
                if (res.code) return layer.alert(res.msg, { icon: 2 });
                layer.alert(res.msg, { icon: 1 });
                setTimeout(() => parent.window.location.reload(), 1000);
            }, 'json');
        }
    </script>
</body>

</html>